/*
 * Copyright 2002-2007 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.springframework.context;

import org.springframework.beans.factory.HierarchicalBeanFactory;
import org.springframework.beans.factory.ListableBeanFactory;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.core.io.support.ResourcePatternResolver;

/**
 * #Comment#:ApplicationContext由BeanFactory派生而来，提供了更多面向世家应用的功能。
 * 在BeanFactory中很多功能以编程的方式实现，而ApplicationContext中可以通过配置的方式进行控制。
 * <p>
 * 中心接口，为一个应用提供配置。在应用运行状态下是只读的，如果实现类支持reload，也可以被reload。<br/>
 * Central interface to provide configuration for an application. This is
 * read-only while the application is running, but may be reloaded if the
 * implementation supports this. <br/>
 * 
 * <p>
 * 一个 ApplicationContext 提供如下:
 * <ul>
 * <li>Bean factory methods for accessing application components. Inherited from
 * {@link org.springframework.beans.factory.ListableBeanFactory}.
 * <li>The ability to load file resources in a generic fashion. Inherited from
 * the {@link org.springframework.core.io.ResourceLoader} interface.
 * <li>The ability to publish events to registered listeners. Inherited from the
 * {@link ApplicationEventPublisher} interface.
 * <li>The ability to resolve messages, supporting internationalization.
 * Inherited from the {@link MessageSource} interface.
 * <li>Inheritance from a parent context. Definitions in a descendant context
 * will always take priority. This means, for example, that a single parent
 * context can be used by an entire web application, while each servlet has its
 * own child context that is independent of that of any other servlet.
 * </ul>
 * 
 * <p>
 * In addition to standard {@link org.springframework.beans.factory.BeanFactory}
 * lifecycle capabilities, ApplicationContext implementations detect and invoke
 * {@link ApplicationContextAware} beans as well as {@link ResourceLoaderAware},
 * {@link ApplicationEventPublisherAware} and {@link MessageSourceAware} beans.
 * 
 * @author Rod Johnson
 * @author Juergen Hoeller
 * @see ConfigurableApplicationContext
 * @see org.springframework.beans.factory.BeanFactory
 * @see org.springframework.core.io.ResourceLoader
 */
public interface ApplicationContext extends ListableBeanFactory,
		HierarchicalBeanFactory, MessageSource, ApplicationEventPublisher,
		ResourcePatternResolver {

	/**
	 * 返回父context，如果没有父context，则这是context hierarchy的root，并返回<code>null</code>
	 * 
	 * @return the parent context, or <code>null</code> if there is no parent
	 */
	ApplicationContext getParent();

	/**
	 * Expose AutowireCapableBeanFactory functionality for this context.
	 * 为当前context暴露AutowireCapableBeanFactory功能。
	 * <p>
	 * This is not typically used by application code, except for the purpose of
	 * initializing bean instances that live outside the application context,
	 * applying the Spring bean lifecycle (fully or partly) to them.
	 * <p>
	 * Alternatively, the internal BeanFactory exposed by the
	 * {@link ConfigurableApplicationContext} interface offers access to the
	 * AutowireCapableBeanFactory interface too. The present method mainly
	 * serves as convenient, specific facility on the ApplicationContext
	 * interface itself.
	 * 
	 * @return the AutowireCapableBeanFactory for this context
	 * @throws IllegalStateException
	 *             if the context does not support the
	 *             AutowireCapableBeanFactory interface or does not hold an
	 *             autowire-capable bean factory yet (usually if
	 *             <code>refresh()</code> has never been called)
	 * @see ConfigurableApplicationContext#refresh()
	 * @see ConfigurableApplicationContext#getBeanFactory()
	 */
	AutowireCapableBeanFactory getAutowireCapableBeanFactory()
			throws IllegalStateException;

	/**
	 * 返回当前context的friendly name
	 * 
	 * @return a display name for this context
	 */
	String getDisplayName();

	/**
	 * 返回当前context首次加载时的时间戳。
	 * 
	 * @return the timestamp (ms) when this context was first loaded
	 */
	long getStartupDate();

}
